import { stringify } from 'qs';
import request from '../utils/request';

export async function fakeAccountLogin(params) {
  return request(`/security/login`, {
    method: 'POST',
    body: params,
  });
}

export async function fakeRegister(account) {
  //console.log(account);
  const requestUrl = `/security/regist?cathcha=${account.captcha}`;
  const bean = { ...account };
  delete bean.confir;
  delete bean.captcha;
  return request(requestUrl, {
    method: 'POST',
    body: bean,
  });
}

export async function getCaptcha(mobile) {
  return request(`/security/captcha/${mobile}`, {
    method: 'POST',
  });
}

export async function step1Validate(payload) {
  const { account: { userName, captcha } } = payload;
  return request(`/security/checkCaptcha/${userName}/${captcha}`, {
    method: 'POST',
  });
}

export async function resetPassword(payload) {
  const requestUrl = `/security/forgetChangePassword?loginName=${payload.loginName}&password=${payload.password}&captcha=${payload.captcha}`;
  return request(requestUrl, {
    method: 'POST',
  });
}
